---
id: dependencyinjectionsettings
title: 4. 依赖注入配置
sidebar_label: 4. 依赖注入配置
---

## 4.1 关于配置

依赖注入配置指的是 `Furion` 框架依赖注入配置选项。

## 4.2 配置信息

- `DependencyInjectionSettings`：依赖注入配置根节点
  - `Definitions`：动态依赖注入配置节点，`ExternalService` 数组类型
    - `ExternalService`：配置单个依赖注入信息
      - `Interface`：配置依赖接口信息，格式：`程序集名称;接口完整名称`，如：`Furion.Application;Furion.Application.ITestService`
      - `Service`：配置接口实现信息，格式同上
      - `RegisterType`：配置依赖注入的对象生存期，取值：`Transient`，`Scoped`，`Singleton`
      - `Action`：注册行为，可选值：`Add`，`TryAdd`，参见 [依赖注入-特性配置](../dependency-injection#128-injection-特性配置)
      - `Pattern`：注册选项，参见 [依赖注入-特性配置置](../dependency-injection#128-injection-特性配置)
      - `Named`：注册别名，参见 [依赖注入-特性配置](../dependency-injection#128-injection-特性配置)
      - `Order`：注册排序，参见 [依赖注入-特性配置](../dependency-injection#128-injection-特性配置)
      - `Proxy`：配置代理拦截，格式：`程序集名称;代理类完整名称`，参见 [依赖注入-特性配置](../dependency-injection#128-injection-特性配置)

## 4.3 配置示例

```json
{
  "DependencyInjectionSettings": {
    "Definitions": [
      {
        "Interface": "Furion.Application;Furion.Application.ITestService",
        "Service": "Furion.Application;Furion.Application.TestService",
        "RegisterType": "Transient",
        "Action": "Add",
        "Pattern": "SelfWithFirstInterface",
        "Named": "TestService",
        "Order": 1,
        "Proxy": "Furion.Application;Furion.Application.LogDispathProxy"
      }
    ]
  }
}
```
